from django import forms


class BookStrap:
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            if field.widget.attrs:
                field.widget.attrs["class"] = "form-control"
                field.widget.attrs["placeholder"] = '请输入%s' % (field.label,)
            else:
                field.widget.attrs = {
                    "class": "form-control",
                    "placeholder": '请输入%s' % (field.label,)
                }


class BookStrapModelForm(BookStrap, forms.ModelForm):
    pass


class BookStrapForm(BookStrap, forms.Form):
    pass
